home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 July: SSW & SDK / Dev.CD Jul 98 SSW-SDK.toast / Development Kits / ColorSync 2.5 SDK / Sample Code / CSDemo 2.5 / ShellSources / win.h < prev   
Encoding:
C/C++ Source or Header  |  1998-05-22  |  7.6 KB  |  236 lines  |  [TEXT/CWIE]

  1.  
  2. #ifndef _WIN_
  3. #define _WIN_
  4.  
  5.  
  6. #ifndef __TYPES__
  7. #include <Types.h>
  8. #endif
  9.  
  10. #ifndef __FILES__
  11. #include <Files.h>
  12. #endif
  13.  
  14. #ifndef __EVENTS__
  15. #include <Events.h>
  16. #endif
  17.  
  18. #ifdef PIGS_SHELL_PRINT
  19. #ifndef __PRINTING__
  20. #include <Printing.h>
  21. #endif
  22. #endif
  23.  
  24.  
  25. /**\
  26. |**| ==============================================================================
  27. |**| PUBLIC DEFINES
  28. |**| ==============================================================================
  29. \**/
  30. #define kDocumentCreator    'ASDF'
  31. #define kWasAlreadyOpen        128
  32.  
  33.  
  34. /**\
  35. |**| ==============================================================================
  36. |**| PUBLIC TYPEDEFS
  37. |**| ==============================================================================
  38. \**/
  39. typedef    struct    _winRecord  winRecord, *winPtr, **winHandle ;
  40.  
  41. /*------------------------------------------------------------------------------*\
  42.     typedefs for the procptrs used by the framework.
  43. \*------------------------------------------------------------------------------*/
  44. typedef    void  (*ActivateProcPtr)    ( winHandle win, Boolean activating ) ;
  45. typedef    void  (*ResumeProcPtr)      ( winHandle win, Boolean resuming ) ;
  46. typedef    void  (*UpdateProcPtr)      ( winHandle win, EventRecord *e) ;
  47. typedef    void  (*ClickProcPtr)       ( winHandle win, EventRecord *e) ;
  48. typedef    void  (*KeyProcPtr)         ( winHandle win, EventRecord *e) ;
  49. typedef    void  (*NullProcPtr)        ( winHandle win, EventRecord *e) ; 
  50. typedef    void  (*MenuProcPtr)        ( winHandle win, long m, Boolean *didit) ;
  51. typedef    void  (*UpdateMenusProcPtr) ( winHandle win ) ;
  52. typedef    void  (*ResizeProcPtr)      ( winHandle win ) ;
  53. typedef    OSErr (*AllocProcPtr)        ( winHandle win ) ; 
  54. typedef    OSErr (*NewProcPtr)         ( winHandle win ) ; 
  55. typedef    OSErr (*OpenProcPtr)        ( winHandle win ) ; 
  56. typedef    void  (*CloseProcPtr)       ( winHandle win ) ; 
  57. typedef    void  (*DisposeProcPtr)        ( winHandle win ) ; 
  58. #ifdef PIGS_SHELL_PRINT
  59. typedef    OSErr (*PageCountProcPtr)   ( winHandle win, short *pageCount ) ; 
  60. typedef    OSErr (*PagePrintProcPtr)   ( winHandle win, GrafPtr imagingPort, short pageNum ) ;
  61. #endif
  62. /*------------------------------------------------------------------------------*\
  63.     winRecord structure used by the framework.
  64. \*------------------------------------------------------------------------------*/
  65. struct    _winRecord {
  66. // type & creator of the windows
  67.     OSType                Creator ;            // always 'ASDF' - helps to verify that it is our window
  68.     OSType                Type ;                // this is the type of window (eg 'Pict' 'Abou', etc.)
  69.     OSType                Subtype ;            // this is the type is free for each window type to use
  70.  
  71. // pocedure pointers
  72.     ActivateProcPtr        ActivateProc;
  73.     ResumeProcPtr        ResumeProc;
  74.     UpdateProcPtr        UpdateProc;
  75.     ClickProcPtr        ClickProc;
  76.     KeyProcPtr            KeyProc;
  77.     NullProcPtr            NullProc;
  78.     MenuProcPtr            MenuProc;
  79.     UpdateMenusProcPtr    UpdateMenusProc;
  80.     ResizeProcPtr        ResizeProc;
  81.     AllocProcPtr        AllocProc;
  82.     NewProcPtr            NewProc;
  83.     OpenProcPtr            OpenProc;
  84.     CloseProcPtr        CloseProc;
  85.     DisposeProcPtr        DisposeProc;
  86. #ifdef PIGS_SHELL_PRINT
  87.     PageCountProcPtr    PageCountProc;
  88.     PagePrintProcPtr    PagePrintProc;
  89. #endif
  90.  
  91. // basic necessities
  92.     FSSpec                FSSpec ;            // file spec for the win, we don't keep it open
  93.     WindowRef            Window ;            // the graf port/window for the document
  94.     Rect                Rect ;                // the bounds of the document
  95.     Rect                SizeRect ;            // the max/min size of the document
  96.     Boolean                Dirty ;             // true if the file needs to be saved
  97.     
  98. #ifdef PIGS_SHELL_PRINT
  99. // print data record (classic)
  100.     THPrint                PrintRec ;            // a print record for the document
  101. #endif
  102.  
  103. //content data
  104.     Handle                Data;                // handle to whatever data this document needs
  105.  
  106. } ;
  107.  
  108. typedef struct AllocProcMap
  109. {
  110.     OSType                filetype ;
  111.     AllocProcPtr        AllocProc ;
  112.     OSType                subtype ;
  113.     Boolean                printable ;
  114.     Boolean                autoNew ;
  115. } AllocProcMapRec, *AllocProcMapPtr, **AllocProcMapHdl ;
  116.  
  117.  
  118.  
  119. /**\
  120. |**| ==============================================================================
  121. |**| PUBLIC FUNCTION PROTOTYPES
  122. |**| ==============================================================================
  123. \**/
  124. OSErr            NewWinHandle        ( winHandle *win, AllocProcPtr allocProc ) ;
  125. OSErr            DisposeWinHandle    ( winHandle win ) ;
  126.  
  127. winHandle        GetWindowWinHandle    ( WindowRef w ) ;
  128. void            SetWindowWinHandle    ( WindowRef w, winHandle win ) ;
  129.  
  130. winHandle        GetFrontWindowWinHandle ( void ) ;
  131. winHandle        FrontWin            ( void ) ;
  132. winHandle        GetNextWin            ( winHandle win ) ;
  133.  
  134. short            FindWinHandle        ( FSSpec *specPtr,
  135.                                       OSType type,
  136.                                       OSType subtype,
  137.                                       short index,
  138.                                       short count,
  139.                                       winHandle *result ) ;
  140.  
  141. static            Boolean    SameFSSpec    ( FSSpec *fs1, FSSpec *fs2 ) ;
  142.  
  143. OSType        GetWinCreator        ( winHandle win ) ;
  144. void        SetWinCreator        ( winHandle win, OSType creator ) ;
  145.  
  146. OSType        GetWinType            ( winHandle win ) ;
  147. void        SetWinType            ( winHandle win, OSType type ) ;
  148.  
  149. OSType        GetWinSubtype        ( winHandle win ) ;
  150. void        SetWinSubtype        ( winHandle win, OSType type ) ;
  151.  
  152. FSSpec        GetWinFSSpec        ( winHandle win ) ;
  153. void        SetWinFSSpec        ( winHandle win, FSSpec *theFSSpec ) ; 
  154.  
  155. WindowRef    GetWinWindow        ( winHandle win ) ;
  156. void        SetWinWindow        ( winHandle win, WindowRef theWindow ) ;
  157.  
  158. Rect        GetWinRect            ( winHandle win ) ;
  159. void        SetWinRect            ( winHandle win, Rect theRect ) ;
  160.  
  161. Rect        GetWinSizeRect        ( winHandle win ) ;
  162. void        SetWinSizeRect        ( winHandle win, Rect theRect ) ;
  163.  
  164. Boolean        GetWinDirty            ( winHandle win ) ;
  165. void        SetWinDirty            ( winHandle win, Boolean dirty ) ;
  166.  
  167. #ifdef PIGS_SHELL_PRINT
  168.  
  169. THPrint        GetWinPrintRec        ( winHandle win ) ;
  170. void        SetWinPrintRec        ( winHandle win, THPrint thePrintRec ) ;
  171.  
  172. #endif
  173.  
  174. Handle        GetWinData            ( winHandle win ) ;
  175. void        SetWinData            ( winHandle win, Handle h ) ;
  176.  
  177.  
  178. void        CallWinActivateProc    ( winHandle win, Boolean activating ) ;
  179. void        SetWinActivateProc    ( winHandle win, ActivateProcPtr f ) ;
  180.  
  181. void        CallWinResumeProc    ( winHandle win, Boolean resuming ) ;
  182. void        SetWinResumeProc    ( winHandle win, ResumeProcPtr f ) ;
  183.  
  184. void        CallWinUpdateProc    ( winHandle win, EventRecord *e ) ;
  185. void        SetWinUpdateProc    ( winHandle win, UpdateProcPtr f ) ;
  186.  
  187. void        CallWinClickProc    ( winHandle win, EventRecord *e ) ;
  188. void        SetWinClickProc        ( winHandle win, ClickProcPtr f ) ;
  189.  
  190. void        CallWinKeyProc        ( winHandle win, EventRecord *e ) ;
  191. void        SetWinKeyProc        ( winHandle win, KeyProcPtr f ) ;
  192.  
  193. void        CallWinNullProc        ( winHandle win, EventRecord *e ) ;
  194. void        SetWinNullProc        ( winHandle win, NullProcPtr f ) ;
  195.  
  196. void        CallWinMenuProc        ( winHandle win, long m, Boolean *didit ) ;
  197. void        SetWinMenuProc        ( winHandle win, MenuProcPtr f ) ;
  198.  
  199. void        CallWinUpdateMenusProc    ( winHandle win ) ;
  200. void        SetWinUpdateMenusProc    ( winHandle win, UpdateMenusProcPtr f ) ;
  201.  
  202. void        CallWinResizeProc    ( winHandle win ) ;
  203. void        SetWinResizeProc    ( winHandle win, ResizeProcPtr f ) ;
  204.  
  205. OSErr        CallWinAllocProc    ( winHandle win ) ;
  206. void        SetWinAllocProc        ( winHandle win, AllocProcPtr f ) ;
  207.  
  208. OSErr        CallWinNewProc        ( winHandle win ) ;
  209. void        SetWinNewProc        ( winHandle win, NewProcPtr f ) ;
  210.  
  211. OSErr        CallWinOpenProc        ( winHandle win ) ;
  212. void        SetWinOpenProc        ( winHandle win, OpenProcPtr f ) ;
  213.  
  214. void        CallWinCloseProc    ( winHandle win ) ;
  215. void        SetWinCloseProc        ( winHandle win, CloseProcPtr f ) ;
  216.  
  217. void        CallWinDisposeProc    ( winHandle win ) ;
  218. void        SetWinDisposeProc    ( winHandle win, DisposeProcPtr f ) ;
  219.  
  220. #ifdef PIGS_SHELL_PRINT
  221.  
  222. OSErr        CallWinPageCountProc    ( winHandle win, short *pageCount ) ;
  223. void        SetWinPageCountProc        ( winHandle win, PageCountProcPtr f ) ;
  224.  
  225. OSErr        CallWinPagePrintProc    ( winHandle win, GrafPtr imagingPort, short pageNum ) ;
  226. void        SetWinPagePrintProc        ( winHandle win, PagePrintProcPtr f ) ;
  227.  
  228. #endif
  229.  
  230. OSErr        CallAllWinNullProcs            ( EventRecord *event ) ;
  231. OSErr        CallAllWinResumeProcs        ( Boolean resuming ) ;
  232. OSErr        CallAllWinUpdateMenusProcs    ( void ) ;
  233. OSErr        CallAllWinMenuProcs            ( long m, Boolean *didit ) ;
  234.  
  235.  
  236. #endif